package com.jsoft.model;

import com.jsoft.dto.ProductDto;
import com.jsoft.model.core.BaseDao;

import javax.persistence.*;

/**
 * Date: 15.08.13
 * Time: 14:37
 */

@Entity
@Table(name = "products")
public class ProductDao extends BaseDao {
    @Column(name = "name")
    private String name;
    @ManyToOne
    @JoinColumn(name = "unit_id")
    private UnitDao unit;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public UnitDao getUnit() {
        return unit;
    }

    public void setUnit(UnitDao unit) {
        this.unit = unit;
    }

    public ProductDto wrapProductDto() {
        ProductDto dto = new ProductDto();
        dto.setId(this.getObjectId());
        dto.setName(this.getName());
        return dto;
    }

    public ProductDao wrapProductDao(ProductDto dto) {
        ProductDao dao = new ProductDao();
        dao.setName(dto.getName());
        return dao;
    }
}
